package com.ds.infrastructure.audit.client.api;

import com.ds.infrastructure.audit.client.enums.KbaProtocol;
import com.ds.infrastructure.audit.client.factory.KbaTrackFactory;
import com.ds.infrastructure.audit.client.track.KbaCallback;
import com.ds.infrastructure.audit.client.track.KbaTrack;
import com.ds.infrastructure.audit.common.entity.KbaBehavior;
import com.ds.infrastructure.audit.common.exception.KbaAuditException;

/**
 * 作用：
 *
 * @author WeiShaoying
 * @date 2020/7/29
 */
public class KbaClient {

    //TODO:
    private static final String serverMQ = "";
    private static final String serverHttp = "";
    private static final String serverRPC = "";
    public static final KbaTrack MQ = KbaTrackFactory.getClient(serverMQ, "", "");
    public static final KbaTrack HTTP = KbaTrackFactory.getClient(KbaProtocol.HTTP, serverHttp);
    public static final KbaTrack ASYNC_HTTP = KbaTrackFactory.getClient(KbaProtocol.ASYNC_HTTP, serverHttp);
    public static final KbaTrack RPC = KbaTrackFactory.getClient(KbaProtocol.RPC, serverRPC);


    /**
     * Kba上报
     *
     * @param behavior
     * @throws KbaAuditException
     */
    public static void report(KbaBehavior behavior) throws KbaAuditException {
        MQ.report(behavior);
    }


    /**
     * 上报并指定回调处理
     *
     * @param behavior
     * @param callback
     * @throws KbaAuditException
     */
    public static void report(KbaBehavior behavior, KbaCallback callback) throws KbaAuditException {
        MQ.report(behavior, callback);
    }

    public static void main(String[] args) {
        KbaClient.report(KbaBehavior.builder().build());
        KbaClient.HTTP.report(KbaBehavior.builder().build());
        KbaClient.ASYNC_HTTP.report(KbaBehavior.builder().build());
        KbaClient.RPC.report(KbaBehavior.builder().build());
    }
}
